package com.lynch.adment;

import java.util.List;


import android.content.Context;
import android.graphics.Bitmap;
import android.widget.Gallery;

/**
 * Gallery回调实现类
 * 
 * @author yjc
 */
public class GalleryCallbackImpl implements GalleryCallback {

	private Context context;
	private Gallery gallery;
	private int bitmapCount;
	private List<Bitmap> bitmapList;

	public GalleryCallbackImpl(Gallery gallery, List<Bitmap> bitmapList,
			int bitmapCount, Context context) {
		super();
		this.gallery = gallery;
		this.bitmapList = bitmapList;
		this.bitmapCount = bitmapCount;
		this.context = context;
	}

	public void galleryLoaded(Bitmap bitmap) {

		if(bitmap!=null){
			bitmapList.add(bitmap);
			if (bitmapList.size() == bitmapCount) {
				ImageAdapter imageAdapter = new ImageAdapter(context, bitmapList);
				gallery.setAdapter(imageAdapter);
			}
		}
	}

}
